
/*
 * Plotting party turnout 2x2
 */

clear all

// Set Folder Path
gl path "~/Dropbox/CovidTurnout/replication"
set scheme plotplain // plotting style

/*
 * load texas data
 */

use "$path/original_data/analysis_file.dta", clear
drop if party==""
keep if age >= 50 & age <=80 
keep if voted==100

replace absentee = absentee/100
replace early = early / 100
collapse absentee early [fw=obs], by(year party age)
egen party_year = concat(year party)

keep if year == 2020

// TX absentee
binscatter absentee age, ///
    name(tx_absentee) ///
	by(party_year) discrete linetype(connect) xline(64.5) ///
	xtitle("Age at Election") ///
	xlab(50(5)80) yscale(range(0 1)) ylab(0(0.25)1) ///
    legend(off) ///
    ytitle("Share of Ballots Cast", size(small)) ///
	text(.6 70 "D (2020)", color(navy) size(small)) ///
    text(.03 72 "R (2020)", color(cranberry) size(small)) ///
    scale(1.3) title("{bf: Share Absentee (Texas)}") ///
    lcolors(navy cranberry) ///
	mcolors(navy cranberry) ///
    msymbol(oh th oh th)

// TX early
binscatter early age, ///
    name(tx_early) ///
	by(party_year) discrete linetype(connect) xline(64.5) ///
	ytitle("") xtitle("Age at Election") ///
	xlab(50(5)80) legend(off) yscale(range(0 1)) ylab(0(0.25)1) ///
    scale(1.3) title("{bf: Share Early (Texas)}") ///
    lcolors(navy cranberry) ///
	mcolors(navy cranberry) ///
    msymbol(oh th oh th)

/* 
 * load indiana data
 */

use "$path/original_data/analysis_file_indiana.dta", clear
drop if party==""
keep if age >= 50 & age <=80
keep if voted==100

replace absentee = absentee/100
replace early = early / 100
collapse absentee early [fw=obs], by(year party age)

egen party_year = concat(year party)

keep if year == 2020 

// IN absentee
binscatter absentee age, ///
    name(in_absentee) ///
	by(party_year) discrete linetype(connect) xline(64.5) ///
	xtitle("Age at Election") ///
    ytitle("Share of Ballots Cast", size(small)) ///
	xlab(50(5)80) legend(off) yscale(range(0 1)) ylab(0(0.25)1) ///
    lcolors(navy cranberry) ///
    mcolors(navy cranberry) ///
    text(.6 70 "D (2020)", color(navy) size(small)) ///
    text(.09 72 "R (2020)", color(cranberry) size(small)) ///
    msymbol(oh th) ///
	scale(1.3) title("{bf: Share Absentee (Indiana)}")

// IN early
binscatter early age, ///
    name(in_early) ///
	by(party_year) discrete linetype(connect) xline(64.5) ///
	ytitle("") xtitle("Age at Election") ///
	xlab(50(5)80) legend(off) yscale(range(0 1)) ylab(0(0.25)1) ///
    lcolors(navy cranberry) ///
    mcolors(navy cranberry) ///
    msymbol(oh th) ///
	scale(1.3) title("{bf: Share Early (Indiana)}")

/* 
 * Put figure together
 */

gr combine tx_absentee tx_early in_absentee in_early, xcommon rows(2) cols(2)
graph export "$path/output/party_combined_plot.pdf", replace
